package com.lwj.liwanjia.adapter;

import android.content.Context;
import android.graphics.Paint;
import android.view.View;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.lwj.liwanjia.R;
import com.lwj.liwanjia.bean.SeckillMoreBean;
import com.superrecycleview.superlibrary.adapter.BaseViewHolder;
import com.superrecycleview.superlibrary.adapter.SuperBaseAdapter;

import java.util.List;

/**
 * Created by Administrator on 2017/9/11.
 */

public class SeckillMoreAdapter extends SuperBaseAdapter<SeckillMoreBean.DataBean.CommendityBean> {

    private Context mContext;

    public SeckillMoreAdapter(Context context, List<SeckillMoreBean.DataBean.CommendityBean> data) {
        super(context, data);
        mContext = context;
    }

    @Override
    protected void convert(BaseViewHolder holder, SeckillMoreBean.DataBean.CommendityBean item, int position) {
        Glide.with(mContext).load(item.getImageUrl()).placeholder(R.mipmap.station).error(R.mipmap.station).into((ImageView) holder.getView(R.id.iv_seckill));
        holder.setText(R.id.tv_seckill_name, item.getCommodityName())
                .setText(R.id.tv_seckill_price, "￥" + item.getNowPrice())
                .setText(R.id.tv_seckill_price1, "￥" + item.getCommodityPrice())
                .setText(R.id.tv_shouchu, "已售" + item.getSoleGoods() + "%");
        ProgressBar progressBar = holder.getView(R.id.my_progressbar);
        progressBar.setProgress(Integer.parseInt(item.getSoleGoods()));
        TextView seckillPrice1 = holder.getView(R.id.tv_seckill_price1);
        seckillPrice1.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);
    }

    @Override
    protected int getItemViewLayoutId(int position, SeckillMoreBean.DataBean.CommendityBean item) {
        return R.layout.sekcill_more_item;
    }
}
